using System;
using System.Windows.Forms;

namespace CustomControls.UserControls
{
    public partial class UserControlBase : UserControl
    {
        private bool _dirtyFlag;

        public bool DirtyFlag
        {
            get { return _dirtyFlag; }
            set
            {
                _dirtyFlag = value;

                if (value)
                {
                    OnEdited(new EventArgs());
                }
            }
        }

        protected UserControlBase()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs argEventArgs)
        {
            if (DesignMode)
            {
                //System.IO.StreamWriter temp = System.IO.File.CreateText(@"C:\$hank\ControlBaseDebugfile.txt");
                //temp.WriteLine("DesignMode");
                //temp.Close();
                return;
            }

            base.OnLoad(argEventArgs);
            //Initialize();
        }

        public virtual void Initialize()
        {
        }

        public virtual void OnApply() //object sender, EventArgs argEventArgs)
        {

        }

        public event EventHandler Edited;

        protected virtual void OnEdited(EventArgs argEventArgs)
        {
            EventHandler handeler = Edited;
            if (handeler != null)
            {
                handeler(this, argEventArgs);
            }
        }


    }
}
